<?php
class Tags_model extends DbManage_model
{

	function __construct()
	{
		parent::__construct();
		$this->load->model('table/tagstable_model','tagstable');
	}
	
	/**
	 * insert one tag
	 *
	 * @param array $arrData,the keys are include tag,agentId
	 * @return return tagid if success o, rerurn false if failed
	 */
	function insertItem($arrData)
	{
		try
		{
			$a=new DbManage_model();
			$this->db->trans_begin();
			$this->tagstable->insert($arrData);
			$this->db->trans_commit();
		}
		catch (Exception $e)
		{
			$this->db->trans_rollback();
			$strMessage=sprintf("%s:%d %s", $e->getFile (), $e->getLine (), $e->getMessage ());
			log_message('error',$strMessage);
			return false;
		}
		return true;
	}

	/**
	 * get tag data 
	 *
	 * @param array $arrWhere conditions
	 * @param array $intLimit limit number
	 * @return return an array including data if success ,return false if failed
	 */
	function normalSearch($arrWhere=array(),$intLimit=0)
	{
		try
		{
			$arrData=$this->tagstable->select($arrWhere,$intLimit);
			return $arrData;
		}
		catch (Exception $e)
		{
			$strMessage=sprintf("%s:%d %s", $e->getFile (), $e->getLine (), $e->getMessage ());
			log_message('error',$strMessage);
			return false;
		}
	}


//	function listSearch($arrWhere,$intLimit)
//	{
//		try
//		{
//			$arrData=$this->tagstable->select($arrWhere,$intLimit);
//			return $arrData;
//		}
//		catch (Exception $e)
//		{
//			$strMessage=sprintf("%s:%d %s", $e->getFile (), $e->getLine (), $e->getMessage ());
//			log_message('error',$strMessage);
//		}
//	}
}
